#!bin/sh


function install::golang(){
    #curl -O https://golang.google.cn/dl/go1.21.11.linux-amd64.tar.gz # 下载后会格式不对
    wget ./ https://golang.google.cn/dl/go1.21.11.linux-amd64.tar.gz

    mkdir -p $HOME/go
    tar -xvzf ./go1.21.11.linux-amd64.tar.gz -C $HOME/go

    mv $HOME/go/go $HOME/go/go1.21.11



    cat << 'EOF' >> $HOME/.zshrc
# Go envs
export GOVERSION=go1.21.11 # Go 版本设置
export GO_INSTALL_DIR=$HOME/go # Go 安装目录
export GOROOT=$GO_INSTALL_DIR/$GOVERSION # GOROOT 设置
export GOPATH=$WORKSPACE/golang # GOPATH 设置
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH # 将 Go 语言自带的和通过 go install 安装的二进制文件加入到 PATH 路径中
export GO111MODULE="on" # 开启 Go moudles 特性
export GOPROXY=https://proxy.golang.com.cn,direct # 安装 Go 模块时，代理服务器设置
export GOPRIVATE=
export GOSUMDB=off # 关闭校验 Go 依赖包的哈希值
EOF

}

function install::rust(){
        cat << 'EOF' >> $HOME/.zshrc
#rust配置相关
export CARGO_HOME=$HOME/rust/cargo
export RUSTUP_HOME=$HOME/rust/rustup
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rus

EOF

    curl https://sh.rustup.rs -sSf | sh #rustup: installer for platform 'x86_64-unknown-linux-gnu' not found, this may be unsupported

    sudo pacman -S rustup

    export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
    rustup toolchain intall stable

    rustup toolchain list
    #rustup default 名称
}
